<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class="app-container">
    <el-form id="mvcfm">
      <el-row>
        <el-col :span="7" :xs="24">
          <div class="form-unit">
            <span class="mvc-title-left"> 时间设置 </span>
          </div>
          <div>
          </div>
          <el-tree :data="tm_firm" :highlight-current="true" class='mvctree' v-loading="treeloading" @node-click="handleNodeClick">
            <span class="el-tree-node__label" slot-scope="{node,data}" v-html="data.__desc"></span>
          </el-tree>
        </el-col>
        <el-col :span="16" :xs="24">
          <el-table :data="s_s_type" v-loading="loading">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="gotoPage('/oa/system/TimeCheck?CMIDcode='+scope.row.code+''+vueparams+'')">检查</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="岗位类型" prop="code">
              <template slot-scope="scope">
                <el-link @click="gotoPage('/oa/system/TimeInsert?&CMID7='+s_s.CMID7+'&CMIDcode='+scope.row.code+''+vueparams+'')" type='primary'>{{scope.row.description}}</el-link>
              </template>
            </el-table-column>
            <el-table-column label="设置人" prop="contact_name">
            </el-table-column>
            <el-table-column label="设置时间" prop="wmenterend">
            </el-table-column>
            <el-table-column label="设置时间范围" prop="time_range">
            </el-table-column>
          </el-table>
          <el-button @click="gotoPage('/oa/system/OvertimeAdd?'+vueparams+'')" type='success' size="mini"><i class='fa fa-plus'></i>增加</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 加班设置 </span>
          </div>
          <el-table :data="s_worktime" v-loading="loading">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="d_worktime('&CMIDtimeid='+scope.row.timeid+'')">删除</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="#" align="center" type='index'>
            </el-table-column>
            <el-table-column label="标题" prop="timeid">
              <template slot-scope="scope">
                <el-link @click="popOvertimedetil('&CMIDtimeid='+scope.row.timeid+'')" type='primary'>{{scope.row.work_title}}</el-link>
              </template>
            </el-table-column>
            <el-table-column label="加班时间" prop="work_day">
            </el-table-column>
            <el-table-column label="设置人" prop="contact_name">
            </el-table-column>
          </el-table>
        </el-col>
      </el-row>
    </el-form>
    <el-dialog :visible.sync="OvertimedetilVisible" append-to-body>
      <Overtimedetil v-if="OvertimedetilVisible" ref="Overtimedetil" :popparams="popparams"> </Overtimedetil>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import Overtimedetil from "@/views/oa/system/Overtimedetil";
  export default {
    name: 'Cartogram',
    components: {
      Overtimedetil,
    },
    props: ['popparams'],
    data() {
      return {
        OvertimedetilVisible: false,
        OvertimedetilValue: null,
        OvertimedetilDesc: null,
        vueparams: this.getVUEParams(""),
        s_s: {
          CMID7: null,
        },
        s_s_type: [],
        s_worktime: [],
        treeloading: true,
        tm_firm: [],
        loading: false,
        rules: {}
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/oa/humanresources/StationAction/cartogram?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
          this["tm_firm"] = this.loadTreeTable(this["tm_firm"], "firm_id", "firm_higher");
          this.treeloading = false;
        })
      },
      getPage(_params) {
        this.loading = true;
        request({
          method: 'post',
          url: '/xcapi/VUEAction/oa/humanresources/StationAction/cartogramPage?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.loading = false;
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      d_worktime(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/oa/humanresources/StationAction/d_worktime?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      popOvertimedetil(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.OvertimedetilVisible = !this.OvertimedetilVisible;
      },
      handleNodeClick(data) {
        this.s_s.CMID7 = data.firm_id;
        this.getPage(1);
      },
    },
  }
</script>
